using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MenuPanel : UIPanel
{
    private Button btnStart;
    private Button btnSetting;
    private Button btnQuit;
    private Button btnHistory;
    
    private void Awake()
    {
        
        btnStart   = transform.Find("StartGame").GetComponent<Button>();
        btnSetting = transform.Find("Setting").GetComponent<Button>();
        btnQuit    = transform.Find("Quit").GetComponent<Button>();
        btnHistory = transform.Find("HistoryLog").GetComponent<Button>();
        btnStart.onClick.AddListener(OnClickStart);
        btnSetting.onClick.AddListener(OnShowSettingPanel);
        btnQuit.onClick.AddListener(OnClickQuit);
        btnHistory.onClick.AddListener(OnClickHistory);
        
    }
    
    void OnClickStart()
    {
        Hide();
        UIManager.Instance.OpenPanel<GamePanel>(); 
        GamePanel m_gamePanel = UIManager.Instance.GetPanelByName<GamePanel>();
        m_gamePanel.NewGame();

        if (GuidancePanel._instance.IsNovice())
        {
            GuidancePanel._instance.NextStep(Const.ClickBtnStart);
        }
       
    }
    
    void OnShowSettingPanel()
    {
        UIManager.Instance.OpenPanel<SettingPanel>();
        if (GuidancePanel._instance.IsNovice())
            GuidancePanel._instance.NextStep(Const.ClickSetting);
    }

    void OnClickHistory()
    {
        UIManager.Instance.OpenPanel<HistoryScorePanel>();
    }

    void OnClickQuit()
    {
        Application.Quit();
    }

  
}
